<%-- 
    Document   : estadoInscripcion
    Created on : 01-ago-2012, 18:43:26
    Author     : Administrador
--%>
<%@include file="../sessionEst.jsp" %>
<%@page import="java.util.Calendar"%>
<%@page import="com.javabeans.Carrera"%>
<%@page import="java.util.List"%>
<%@page import="com.javabeans.Gestion"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    int i = 0;
    int year = s_now.get(Calendar.YEAR);
    List<Gestion> gestiones = (List<Gestion>)request.getAttribute("gestiones");
    List<Carrera> carreras = (List<Carrera>)request.getAttribute("carreras");
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>SI-ESFM </title>
        <meta name="description" content="Derechos Reservados SI-ESFM." />
        <link rel="stylesheet" href="css/styles.css" type="text/css" />
        <link rel="stylesheet" href="css/menu/style.css" type="text/css" />
        <link rel="shortcut icon" href="images/ico.png" type="image/png"/>
        <script type="text/javascript" src="<%=s_path%>/js/jquery-1.7.2.min.js"></script>
        <script type="text/javascript" src="<%=s_path%>/js/validate/jquery.validate.min.js"></script>
        <script type="text/javascript" src="<%=s_path%>/js/comun.js"></script>
        <style type="text/css">
            div.medio center p{width:95%;float:left;font-size:13px;color:#000000;line-height:21px;padding-bottom:35px;}
        </style>
        <script type="text/javascript">
        <%
            i=0;
            out.println(" gestiones = new Array();");
            for(Gestion g:gestiones){
                out.print(" gestiones["+i+"] = new Array("+g.getIdGestion()+","+g.getIdFacultad()+","+g.getYear()+",'"+g.getNombre()+"'); ");
                i++;
            }
            i = 0;
        %>
            
            $(document).ready(function(){
                $("#formRepHorario").validate({
                    submitHandler: function(form){
                        $("#carrera option:selected").each(function (){
                            var valor = $(this).val();
                            valor = valor.split("_");
                            $("#idCarrera").val(valor[0]);
                            $("#idFacultad").val(valor[1]);
                            $("#nomCarrera").val($(this).text());
                        });
                        $("#idGestion option:selected").each(function (){
                            $("#nomGestion").val($(this).text());
                        });
                        $.ajax({
                            type: 'POST',
                            url: 'InfAcademicaEst',
                            data: $('#formRepHorario').serialize(),
                            success: function(res) {
                                $('#inscritos').html(res);
                            },
                            error:function(){alert("Error! al optener el estado de inscripci&oacute;n")}
                        })
                    }
                });
                
                $("#carrera").change(function(){ // si cambia de carrera llenamos las gestiones de dicha Unidad Académica
                    $("#carrera option:selected").each(function (){
                        var value = $(this).val();
                        text = '<option value="">Seleccione Gesti&oacute;n</option>';
                        if(value.length > 0){
                            value = value.split("_");
                            idFacultad = value[1];
                            for(i=0; i<gestiones.length; i++){
                                if(idFacultad == gestiones[i][1]){
                                  text += '<option value="'+gestiones[i][0]+'">'+gestiones[i][3]+'</option>';
                                }
                            }
                            
                        }
                        $("#idGestion").html(text);
                    });
                });
            });
        </script>
    </head>
    <body onload="showTime(<%=s_param%>)">
        <div id="top-wrap">
            <!-- cabeza principal -->
            <%@include file="../headEst.jsp" %>
            <!-- cuerpo -->
            <div id="bodySpace">
                <!-- aqui va la ruta -->
                <div class="clearfix" id="middle" style="position: absolute">
                    <!-- aqui va el arbol de entrada -->
                    <div id="breadcrumb"><!-- le da la forma de la imagen -->
                        <ul>
                            <li><a href="Principal?accion=1&v1=<%=s_idEstudiante%>&v2=<%=s_psw%>">Home</a></li>
                            <li><span style="color:#666">Informaci&oacute;n Acad&eacute;mica</span></li>
                            <li class="current-page"><span class="end"><span class="middle">Horario de Clases</span></span></li>
                        </ul>                      
                    </div><!-- begin SIDEBAR FIRST -->
                </div>
                <div id="principal">
                    <div class="cuerpo2y" style="border: 0px solid"><br/><br/>
                        <div class="izq" style="">
                            <div id="menuprin">
                                <div class="menuIzqMarco">
                                    <div class="menu_css">
                                        <h3 class="title">Seleccione</h3>
                                        <div class="menu_selected menu_selectedDepen">
                                            <ul class="menuLogoNone">
                                                <li class=""><span><a href="InfAcademicaEst?accion=4" title="Pulse aqu&iacute; para ver kardex">Kardex</a></span><span class="end"></span></li>
                                                <li class=""><span><a href="InfAcademicaEst?accion=4" title="Pulse aqu&iacute; para ver horarios">Horario de Clases</a></span><span class="end"></span></li>
                                                <li class="pintar"><span><a href="InfAcademicaEst?accion=6" title="Pulse aqu&iacute; para ver su Estado de Inscripci&oacute;n">Estado de Inscripci&oacute;n</a></span><span class="end"></span></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="medio" style="border: 0px solid">
                            
                            <h2 class="decorado">HORARIO DE CLASES</h2>
                           <form id="formRepHorario">
                               <input type="hidden" name="accion" value="7" />
                               <input type="hidden" name="idCarrera" id="idCarrera" value="" />
                               <input type="hidden" name="idFacultad" id="idFacultad" value="" />
                               <input type="hidden" name="nomCarrera" id="nomCarrera" value="" />
                               <input type="hidden" name="nomGestion" id="nomGestion" value="" />
                            <div style="clear:both;">
                                <label class="form_align35" >Carrera : </label>    
                                <select name="carrera" id="carrera" class="form_input_align required" title="Seleccione Unidad Acad&eacute;mica">
                           <%
                                int idFacultad = 0;
                                if(carreras.size() == 1){
                                    Carrera c = (Carrera)carreras.get(0);
                                    idFacultad = c.getIdFacultad();
                                    out.println("<option value='"+c.getIdCarrera()+"_"+c.getIdFacultad()+"'>"+c.getNombre()+"</option>");
                                }else{
                                    out.println("<option value=''>Seleccione Carrera</option>");
                                    for(Carrera c:carreras){
                                        out.println("<option value='"+c.getIdCarrera()+"_"+c.getIdFacultad()+"'>"+c.getNombre()+"</option>");
                                    }
                                }
                            %>
                                </select>
                                <label class="error">*</label>
                            </div>
                            <div style="clear:both;">
                                <label class="form_align35" >A&ntilde;o : </label>    
                                    <select name="year" id="year" class="form_input_align required">
                                <%
                                    int yearMin = year - 15;
                                    while(year > yearMin){
                                        out.println("<option value='"+year+"'>"+year+"</option>");
                                        year--;
                                    }
                                    year = year + 15;
                                %>
                                    </select>
                                    <label class="error">*</label>
                            </div>
                            <div style="clear:both;">
                                <label class="form_align35" >Gesti&oacute;n : </label>    
                                <select name="idGestion" id="idGestion" class="form_input_align required" title="Seleccione una gesti&oacute;n">
                                <%
                                    i = 0;
                                    out.println("<option value=''>Seleccione una Gesti&oacute;n</option>");
                                    for(Gestion g:gestiones){
                                        if(g.getYear() == year && idFacultad == g.getIdFacultad()){
                                            out.println("<option value='"+g.getIdGestion()+"'>"+g.getNombre()+"</option>");
                                        }
                                    }
                                %>
                                </select>
                                <label class="error">*</label>
                            </div>
                            <div class="form_center" style="clear:both;">
                                <input type="submit" value="Ver Estado de Inscripci&oacute;n" id="botonVer" class="boton" title="Pulsa par ver el estado de inscripci&oacute;n"/>
                            </div>
                           </form>    
                            <br/>
                            <div id="inscritos"></div>
                        </div>
                    </div>
                    <div class="yDer" style="border: 1px solid #ccc;">
                        <%@include file="../../publicidad.jsp" %>                       
                    </div><!--end of rightPan-->
                </div>
            </div>
            <!-- footer -->
            
        </div>
    </body>
</html>
